#include "my_label.h"
#include<QMouseEvent>
#include<QDebug>

my_label::my_label(QWidget *parent) : QLabel(parent)
{
    //一打开就有效
//    this->setMouseTracking(true);// move
}

void my_label::mousePressEvent(QMouseEvent *ev){
    auto i = ev->x();
    auto j = ev->y();

    auto text = QString("<center><h1>Mouse press:(%1,%2)</h1></center>")
            .arg(i).arg(j);
    this->setText(text);

    if(ev->button() == Qt::LeftButton){

    }
    switch (ev->button()) {
    case Qt::LeftButton:
        qDebug()<<"left button of mouse";
    case Qt::RightButton:
        qDebug()<<"right button of mouse";

    case Qt::MidButton:
        qDebug()<<"middle button of mouse";

    }

    QLabel::mousePressEvent(ev);


}
void my_label::mouseReleaseEvent(QMouseEvent *ev){

}
void my_label::mouseMoveEvent(QMouseEvent *ev){

}
